<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
        #app{
            border-left: 1px solid purple;
        }
        span{
            list-style: none;
            padding: 0 8px;
            border-top: 1px solid purple;
            border-right: 1px solid purple;
            cursor: default;
        }
        img{
            display: none;
            width: 300px;
            height: 200px;
            border-right: 1px solid purple;
            border-bottom: 1px solid purple;
        }
        .active{
            background-color: orange;
        }
        .show{
            display: block;
        }
    </style>
</head>
<body>
    <div id="app">
        <span :class="currentIndex == index ? 'active':''" v-on:click="change(index)" :key="item.id" v-for="(item,index) in fruit">{{ item.name }}</span>
        <img :class="currentIndex == index ? 'show':''" :key="index" v-for="(item,index) in fruit" :src="item.img">
    </div>
    

    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                currentIndex: 0,
                fruit:[{
                    id: 4,
                    name: 'apple',
                    img: 'images/apple.jpg'
                },{
                    id: 5,
                    name: 'orange',
                    img: 'images/orange.jpg'
                },{
                    id: 6,
                    name: 'lemon',
                    img: 'images/lemon.png'
                }]
            },
            methods: {
                change: function(index){
                    this.currentIndex = index;
                }
            }
        })

    </script>


</body>
</html>